package com.lj.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @Author: Mr.Liu
 * @Description:
 * @Date Created in 2021-02-10 16:34
 * @Modified By:
 */
@WebServlet(value = "/dianzan")
public class dzServlet extends HttpServlet {
    static  int i=0;
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String add = req.getParameter("add");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        System.out.println(add);
        if(add.equals("加")){
            i=i+1;
            writer.print(i);
        }else{
            i=i-1;
            writer.print(i);
        }
   }
}
